package com.example.ordersystem.service;


import com.example.ordersystem.dao.MerchantDAOByMybatis;
import com.example.ordersystem.domain.Merchant;
import com.example.ordersystem.domain.RoomAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MerchantService {

    @Autowired
    MerchantDAOByMybatis merchantDAOByMybatis;

    public RoomAddress findRoomByName(String merchantaddress) {
        return merchantDAOByMybatis.findRoomByName(merchantaddress);
    }

    /**
     * 商家登录检查
     * @param num 商家账户
     * @param pwd 密码
     * @return
     */
    public Merchant merchantLoginCheck(int num, String pwd) {
        return merchantDAOByMybatis.merchantLoginCheck(num,pwd);
    }

    /**
     * 商家登录，手机-验证码
     * @param tel 手机号码
     * @return null商家不存在;non-null 商家存在
     */
    public Merchant merchantSMSLoginCheck(String tel) {
        return merchantDAOByMybatis.findMerchantByTel(tel);
    }

    /**
     * 商家修改密码
     * @param num 商家账号
     * @param newPass 新的密码
     */
    public void modifyPass(int num,String newPass){
        merchantDAOByMybatis.modifyPass(num,newPass);
    }

    public List<RoomAddress> findAllRoom() {
        return merchantDAOByMybatis.findAllRoom();
    }

    public void deleteAddress(String addressName) {
        merchantDAOByMybatis.deleteAddressByName(addressName);
    }

    public void addAddress(String name, String address, String lng, String lat) {
        merchantDAOByMybatis.addAddress(name,address,lng,lat);
    }


}
